package org.jkuang.qstar.index.test.pc;

import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.List;
import java.util.Map;

import org.jkuang.qstar.commons.io.FileOperator;
import org.jkuang.qstar.commons.jni.CurMap;
import org.jkuang.qstar.commons.jni.DicMap;
import org.jkuang.qstar.index.dic.TermsDic;
import org.jkuang.qstar.index.filter.ResultFilter;
import org.jkuang.qstar.index.store.DataNode;

public class Printer implements ResultFilter {

	@Override
	public boolean accept(DataNode node, TermsDic dic, CurMap data) {
		System.out.println(new String(data.get(node.key()), charset));
		return true;
	}

	@Override
	public void print() {
		// TODO Auto-generated method stub

	}

	@Override
	public Map<Long, byte[]> result() {
		// TODO Auto-generated method stub
		return null;
	}

	public static void main(String[] args) throws IOException {
		List<String> list = FileOperator.readFile(new File("dic.txt"));
		TermsDic map = new TermsDic(true);
		for (String line : list) {
			map.add(line);
		}
		System.out.println(map.get("targetCode:000766"));
	}

}
